<?php
/**	
*	FILENAME: 		/server_app/newswire_story.php
*	DESCRIPTION:	This backend script produces a JSON response including the story title and body given a current Newswire story ID.
*	AUTHOR:			Casey Burkhardt
*	VERSION:		1.0.0
*	LAST MODIFIED:	1/6/2009
**/

require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/newswire.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/functions.php");

enforceSSL();

$storyID = $_POST["story_id"];

if (strlen($storyID) == 0) {
	$response["response_type"] = "error";
	$response["error_desc"] = "Newswire story ID not provided.";
	echo(json_encode($response));
	die();
} else {
	// Obtain the issue and section information
	$timeStamp = getNewswireTimestamp();
	$storyData = getStory($storyID);

	// Check the returned results for validity.
	if ($timeStamp === FALSE || $storyData === FALSE) {
		$response["response_type"] = "error";
		$response["error_desc"] = "Unable to obtain Wildcat Newswire information.";
		echo(json_encode($response));
		die();
	} else {
		$response["response_type"] = "success";
		$response["issue_timestamp"] = $timeStamp;
		$response["story_data"] = $storyData;
		echo(json_encode($response));
		die();	
	}
}
?>